class Cal {
  static const NKeys = [
    "9", "8", "7", //,
    "6", "5", "4", //
    "3", "2", "1", //
    "0", ".", //
  ];

  static const TKeys = [
    "C",
    "del",
    "?",
  ];

  List<String> _keys = [];

  static const RKeys = ["÷", "x", "-", "+"];

  static const EQ = "=";

  List HistoryList = [
    [
      ['','11'],
      ['*','11'],
      ['=','121'],
    ],
    [
      ['','11'],
      ['+','86'],
      ['=','100'],
    ],
    [
      ['','11'],
      ['÷','11'],
      ['=','1'],
    ],
  ];

  List RecentList = [
    [
      ['','0']
    ]
  ];

  String rNum = "";
  String rSign = "";
  String key = '';
  void RecentListToString(v){
    
    for(var i = 0; i<v[0].length;i++){
      key += v[0][i][0];
      key += v[0][i][1];
    }
  }

  void addKey (String num){
    

    

    // print(num);
    switch (num) {
      case 'C':
        RecentList = [
          [
            ['','0']
          ]
        ];

        rNum = "";
        rSign = "";
        key = "";
        return;  
    }
    //输入的为等于号
    if(EQ.contains(num)){

    }else{
      //输入的为数字
      if(NKeys.contains(num)){
        rNum+=num;
        if(RecentList[0].length == 1){
          RecentList[0][0][1] = rNum;
        }else{
          // RecentList[0].removeAt(RecentList[0].length-1);
          RecentList[0][RecentList[0].length-1][1] = rNum;
        }
        
      } 
      //输入的为符号
      if(RKeys.contains(num)){
        rSign = num;
        rNum='';
        if(RecentList[0].length == 1){
          RecentList[0].add([rSign,'']);
        }else{
          if(RecentList[0][RecentList[0].length-1][1]==''){
            RecentList[0][RecentList[0].length-1][0] = rSign;
            // RecentList[0].removeAt(RecentList[0].length-1);
          }else{
            print(22);
            // RecentList[0].removeAt(RecentList[0].length-1);
            RecentList[0].add([rSign,'']);
          }
        }


      }

      // if(RecentList[0].length == 1){
      //   RecentList[0].add(['=',rNum]);
      // }else{
      //   RecentList[0].add(['=',rNum]);
      // }
      RecentListToString(RecentList);
      print(key);
    }
  }
}

